/** CS2340 Spring 2011 Project
 *  Team: 40 Jiggawatt Hard Driver
 *  Suk Hwan Hong
 *  Rhys Saraceni
 *  Travis Cooper
 *  Luke Stubb
 *
 * @author 40 Jiggawatt Hard Driver
 * @version 1.0 
 */

package edu.gatech.jiggawatt.office.model;

import java.io.Serializable;

/**
 * Represents Time
 * @author 40 Jiggawatt Hard Driver
 * @version 1.0
 *
 */
public class Time implements Comparable<Time>, Serializable // $codepro.audit.disable declareDefaultConstructors
{
	private int hours;
	private int minutes;
	

	/**
	 * Creates time
	 * @param hours
	 * @param minutes
	 */
	public Time(int hours, int minutes)
	{
		this.hours = hours;
		this.minutes = minutes;
	}
	
	/**
	 * gets hours
	 * @return hours
	 */
	public int getHours()
	{
		return hours;
	}
	
	/**
	 * gets minutes
	 * @return minutes
	 */
	public int getMinutes()
	{
		return minutes;
	}
	
	/**
	 * sets hours
	 * @param hours
	 */
	public void setHours(int hours)
	{
		this.hours = hours;
	}
	
	/**
	 * sets minutes
	 * @param minutes
	 */
	public void setMinutes(int minutes)
	{
		this.minutes = minutes;
	}
	
	/**
	 * returns string format of time
	 * @return string format of time
	 */
	public String toString()
	{
		if (0 == minutes)
		{
			return hours + ":00"; // $codepro.audit.disable stringLiterals
		}
		else
		{
			return hours + ":" + minutes;
		}
	}
	
	/**
	 * test for equality
	 * @param time other time to check for equality
	 * @return true if equals, false otherwise
	 */
	public boolean equals(Time time) // $codepro.audit.disable checkTypeInEquals, com.instantiations.assist.eclipse.analysis.audit.rule.effectivejava.obeyEqualsContract.obeyGeneralContractOfEquals
	{
		return hours == time.getHours() && minutes == time.getMinutes();
	}
	
	/**
	 * compares to other time
	 * @param time other time to compare
	 * @return 1 if greater, 0 if equals, -1 if less
	 */
	public int compareTo(Time time)
	{
        if (hours == time.getHours() && minutes == time.getMinutes())
        {
        	return 0;
        }
        else if (hours < time.getHours())
        {
        	return -1;
        }
        else if (hours > time.getHours())
        {
        	return 1;
        }
        else if (minutes < time.getMinutes())
        {
        	return -1;
        }
        else
        {
        	return 1;
        }
	}
}
